package src.dominio;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class CalculadoraTest extends TestCase {

	Calculadora calcular;
	
	//@Before
	public void setUp() throws Exception {
		
		calcular=new Calculadora();
	}

	//@After
	public void tearDown() throws Exception {
	}

	//@Test
	public void testSuma() {
		
		double x=3.5,y=1;
		assertEquals(calcular.suma(x, y),4.5);
		
		x=-3.5;
		y=-1;
		assertEquals(calcular(x, y),-4.5);
		
		x=0;
		y=-2;
		assertEquals(calcular.suma(x, y),-2.0);
		
		x=0;
		y=1;
		assertEquals(calcular.suma(x, y),1.0);
		
		x=0;
		y=0;
		assertEquals(calcular.suma(x, y),0.0);
		
	}

	//@Test
	public void testResta() {
		
		double x=6,y=3.5;
		assertEquals(calcular.resta(x, y),2.5);
		
		x=-3.5;
		y=-6;
		assertEquals(calcular.resta(x, y),-9.5);
		
		x=0;
		y=-1;
		assertEquals(calcular.resta(x, y),+1.0);
		
		x=0;
		y=1;
		assertEquals(calcular.resta(x, y),-1.0);
		
		x=0;
		y=0;
		assertEquals(calcular.resta(x, y),0.0);
		
	}

	//@Test
	public void testMultiplica() {
		double x=1,y=4;
		assertEquals(calcular.multiplica(x, y),4.0);
		
		x=0;
		y=-1;
		assertEquals(calcular.multiplica(x, y),-0.0);
		
		x=4;
		y=-5.5;
		assertEquals(calcular.multiplica(x, y),-22.0);
		
		x=0;
		y=1;
		assertEquals(calcular.multiplica(x, y),0.0);
		
		x=0;
		y=0;
		assertEquals(calcular.multiplica(x, y),0.0);
		
		
	}

	//@Test
	public void testDivide() {
		double x=1,y=2;
		assertEquals(calcular.divide(x, y),0.5);
		
		x=-2;
		y=-4;
		assertEquals(calcular.divide(x, y),0.5);
		
		x=0;
		y=-1;
		assertEquals(calcular.divide(x, y),-0.0);
		
		x=0;
		y=1;
		assertEquals(calcular.divide(x, y),0.0);
		
		x=4;
		y=-2;
		assertEquals(calcular.divide(x,y),-2.0);
		
		x=0;
		y=0;
		try{
			calcular.divide(x,y);
		}catch (ArithmeticException E)
		{
			assertEquals(0, 0);
		}
	}

}
